const Mock = require('mockjs')

//处理前端传来的参数
function handleData(res: any) {
  return JSON.parse(res.body)
}

let data = Mock.mock({
  "data": {
    "id": /^0x[a-f0-9]{18}$/,//16进制随机数
  }
})
//用户登录接口
Mock.mock(/user\/users\/login/, 'post', (res: any) => {
  let loginInfo = handleData(res)
  let result = {
    status: 200,
    msg: '登录成功',
    token: data.data.id,
    loginInfo
  }
  return result
})

//左侧菜单栏数据
let slider_left = [
  {
    id: 100,
    name: '数据管理',
    icon: 'icon-shujutongji',
    children: [
      {
        id: 1000,
        name: '表格管理',
        icon: 'icon-shujutongji',
        path:'/TableManagement'
      },
      {
        id: 1001,
        name: '图表管理',
        icon: 'icon-shujutongji',
        path:'/ChartManagement'
      },
      {
        id: 1002,
        name: '表单管理',
        icon: 'icon-shujutongji',
        path:'/FormManagement'
      },
    ]
  },
  {
    id: '101',
    name: '账户管理',
    icon: 'icon-shujutongji',
    children: [
      {
        id: '1004',
        name: '账户管理',
        icon: 'icon-shujutongji',
        path:'/home/AccountManagement'
      }
    ]
  }
]
//左侧菜单栏数据接口
Mock.mock(/user\/users\/getsilder/, 'get', () => {
  return slider_left
})